<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 600px;
            margin: 100px auto;
        }
        
        .message {
            display: inline-block;
            font-size: 12px;
            color: #999;
            background: url('C:/java-script_learning/image/mess.png') no-repeat left center;
            padding-left: 20px;
        }
        .error {
            color: red;
            background: url('C:/java-script_learning/image/wrong.png') no-repeat left center;
        }
        .right {
            color: green;
            background: url('C:/java-script_learning/image/right.png') no-repeat left center;
        }
    </style>
</head>
<body>
    <div>
        <input type="password" class="ipt">
        <p class="message">请输入6~14位密码</p>
    </div>
    <script>
        var ipt = document.querySelector('.ipt');
        var p = document.querySelector('.message');
        ipt.onblur = function() {
            if(ipt.value.length < 6 || ipt.value.length > 14){
                p.className = 'message error';
                p.innerHTML = '输入错误';
            }else {
                p.className = 'message right';
                p.innerHTML = '通过';
            }
        }
    </script>
</body>
</html>